SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[pageFlow_InstanceStateStore](
	[InstanceID] [uniqueidentifier] NOT NULL,
	[BinaryState] [image] NOT NULL,
 CONSTRAINT [PK_pageFlowInstanceStateStore] PRIMARY KEY CLUSTERED 
(
	[InstanceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


GO
CREATE PROCEDURE [dbo].[pageFlow_InsertInstanceState]
	@instanceID UNIQUEIDENTIFIER, 
	@binaryState image
AS
INSERT INTO pageFlow_InstanceStateStore (InstanceID, 
									BinaryState)
VALUES (@instanceID, 
		@binaryState)
		


GO
CREATE PROCEDURE [dbo].[pageFlow_RemoveInstanceState]
	@instanceID UNIQUEIDENTIFIER
AS
DELETE FROM pageFlow_InstanceStateStore 
WHERE
	InstanceID = @instanceId
	


GO
CREATE PROCEDURE [dbo].[pageFlow_GetInstanceState]
	@instanceID UNIQUEIDENTIFIER
AS
SELECT
	BinaryState
FROM 
	dbo.pageFlow_InstanceStateStore
WHERE
	InstanceID = @instanceID
	
	
GO
CREATE PROCEDURE [dbo].[pageFlow_UpdateInstanceState]
	@instanceID UNIQUEIDENTIFIER, 
	@binaryState image
AS
UPDATE pageFlow_InstanceStateStore 
SET BinaryState = @binaryState
WHERE InstanceID = @instanceID